package com.lineage.server.command.executor;

import com.lineage.config.Config;
import com.lineage.config.ConfigAi;
import com.lineage.config.ConfigAlt;
import com.lineage.config.ConfigBad;
import com.lineage.config.ConfigCharSetting;
import com.lineage.config.ConfigClan;
import com.lineage.config.ConfigDarkElfSkill;
import com.lineage.config.ConfigDragonKnightSkill;
import com.lineage.config.ConfigElfSkill;
import com.lineage.config.ConfigGuaji;
import com.lineage.config.ConfigIllusionstSkill;
import com.lineage.config.ConfigIpCheck;
import com.lineage.config.ConfigKnightSkill;
import com.lineage.config.ConfigOther;
import com.lineage.config.ConfigPrinceSkill;
import com.lineage.config.ConfigRate;
import com.lineage.config.ConfigRecord;
import com.lineage.config.ConfigSQL;
import com.lineage.config.ConfigWho;
import com.lineage.config.ConfigWizardSkill;
import com.lineage.config.Config_Pc_Damage;
import com.lineage.config.Configtf;
import com.lineage.config.Configtype;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1ReLoadConfig implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1ReLoadConfig.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1ReLoadConfig();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入Config设置。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入Config设置"));
      } 
      Config.load();
      ConfigAlt.load();
      ConfigCharSetting.load();
      ConfigOther.load();
      Config_Pc_Damage.load();
      ConfigRate.load();
      ConfigSQL.load();
      ConfigRecord.load();
      ConfigWho.load();
      ConfigBad.load();
      Configtype.load();
      ConfigAi.load();
      Configtf.load();
      ConfigIpCheck.load();
      ConfigClan.load();
      ConfigGuaji.load();
      ConfigPrinceSkill.load();
      ConfigKnightSkill.load();
      ConfigElfSkill.load();
      ConfigWizardSkill.load();
      ConfigDarkElfSkill.load();
      ConfigDragonKnightSkill.load();
      ConfigIllusionstSkill.load();
    } catch (Exception e) {
      _log.info("错误的 GM 指令格式: " + getClass().getSimpleName() + 
          " 执行 GM :" + pc.getName());
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
    } 
  }
}
